import React from 'react';
import { Router, IndexRoute, Route, Redirect, routerRedux } from 'dva/router';

// 登录
import Login from './routes/Login/index';
// 首页布局
import Layout from './routes/Home/layout';

// 资讯
import TrendDetail from './routes/Infor/subpage/trendDetail';
import MienDetail from './routes/Infor/subpage/mienDetail';

// 消息
import PartyCircle from './routes/News/subpage/partyCircle';
import NewTask from './routes/News/subpage/newTask';
import SysNews from './routes/News/subpage/sysNews';
import NewsAdd from './routes/News/subpage/newsAdd';
import PhotoDetail from './routes/News/subpage/photoDetail';
import Meeting from './routes/News/subpage/meetingNotice';

// 工作台
import OrgArchitecture from './routes/Work/OrgArchitecture/orgArchitecture';
import OrgDetail from './routes/Work/OrgArchitecture/subpage/orgDetail';
import TaskManage from './routes/Work/TaskManage/taskManage';
import TaskAdd from './routes/Work/TaskManage/subpage/taskAdd';
import TaskStart from './routes/Work/TaskManage/subpage/taskStart';
import TaskGetOn from './routes/Work/TaskManage/subpage/taskGetOn';
import Complete from './routes/Work/TaskManage/subpage/complete';
import NotComplete from './routes/Work/TaskManage/subpage/notComplete';
import WorkLog from './routes/Work/WorkLog/workLog';
import WorkAdd from './routes/Work/WorkLog/subpage/workAdd';
import WorkDetails from './routes/Work/WorkLog/subpage/workDetails';
import InforRelease from './routes/Work/InforRelease/inforRelease';
import InfroAdd from './routes/Work/InforRelease/subpage/inforAdd';
import InforDetails from './routes/Work/InforRelease/subpage/inforDetails';

// 党员管理
import myinformmation from './routes/Work/Personalinformation/personalinformation';// 个人信息
import Life from './routes/Work/Organizationallife/organizationallife';// 组织生活
import Lifeparticulars from './routes/Work/Organizationallife/LifeParticulars/lifeparticulars';
import Dues from './routes/Work/Dues/dues';// 党费交纳
import Paymenthistory from './routes/Work/Dues/PaymentHistory/paymenthistory';
import ZZGX from './routes/Work/Zzgx/zzgx';// 关系转接
import ApplyTransferxx from './routes/Work/Zzgx/Applytransfer/applytransfer';
import TransferDetails from './routes/Work/Zzgx/Applytransfer/transferdetails';
import ApplyHistory from './routes/Work/Zzgx/History/history';
import ZXXX from './routes/Work/Zxxx/zxxx';// 在线学习
import Particular from './routes/Work/Zxxx/Particulars/particulars';
import ZDSC from './routes/Work/Zdsc/zdsc';// 制度速查
import Communication from './routes/Work/Communication/communication';// 沟通交流
import GRJF from './routes/Work/Grjf/grjf';// 个人积分

// 党务管理
import zzadminister from './routes/Work/Zzadminister/zzadminister';
import Partybuilding from './routes/Work/Zzadminister/PartyBuilding/partybuilding';
import DangyuanList from './routes/Work/Zzadminister/PartyBuilding/dangyuanlist';
import dyadminister from './routes/Work/Dyadminister/dyadminister';
import DyadministerChild from './routes/Work/Dyadminister/dyadminChild/dyadministerChild';
import dfadminister from './routes/Work/Dfadminister/dfadminister';
import hdadminister from './routes/Work/Hdadminister/hdadminister';
import Activityentry from './routes/Work/Hdadminister/ActivityEntry/activityentry';
import rwadminister from './routes/Work/Rwadminister/rwadminister';
import Relation from './routes/Work/Relation/relation';
import Relationlist from './routes/Work/Relation/RelationList/relationlist';
import TParticulars from './routes/Work/Relation/RelationList/toparticulars';
import Releasetask from './routes/Work/Rwadminister/Releasetask/releasetask';
import RwAudit from './routes/Work/Rwadminister/Rwaudit/rwaudit';
import RwRejectex from './routes/Work/Rwadminister/RwRejected/rwrejected';
import djsupervises from './routes/Work/Djsupervises/djsupervises';
import democraticappraisal from './routes/Work/DemocraticAppraisal/democraticappraisal';
import DreviewDetail from './routes/Work/DemocraticAppraisal/dreviewDetail';
import AddAppraisal from './routes/Work/DemocraticAppraisal/Addappraisal/addappraisal';
import dysupportxx from './routes/Work/Dysupport/dysupport';
import Support from './routes/Work/Dysupport/SupportParticulars/supportparticulars';
import Dwreportlist from './routes/Work/Dwreport/dwreportlist';
import Dwreportx from './routes/Work/Dwreport/dwreport';
import partyofintegralxx from './routes/Work/Partyofintegral/partyofintegral';

// 我的
import Selfinfo from './routes/Mine/selfinfo/selfInfo';
import ChangePWD from './routes/Mine/selfinfo/changepwd';
import ChangePhone from './routes/Mine/selfinfo/changephone';
//  import Point from  './routes/Mine/selfinfo/point'原积分页面
import Collection from './routes/Mine/selfinfo/collection';
import Task from './routes/Mine/selfinfo/task';
import TaskParticulars from './routes/Mine/selfinfo/taskParticulars/taskparticulars';
import MyCard from './routes/Mine/selfinfo/myCard';
import MyWeb from './routes/Mine/selfinfo/myweb';
import MyWebInfo from './routes/Mine/selfinfo/WebsiteDetail/websiteDetail';
import MyActivity from './routes/Mine/selfinfo/MyActivity/myActivity';
import MyCourse from './routes/Mine/selfinfo/MyCourse/myCourse';
import MyRelease from './routes/Mine/selfinfo/MyRelease/myRelease';
import MySetUp from './routes/Mine/selfinfo/MySetUp/mySetUp';
import IntegralRule from './routes/Mine/selfinfo/MySetUp/IntegralRule/integralRule';
import UseGuide from './routes/Mine/selfinfo/MySetUp/UseGuide/useGuide';
import Feedback from './routes/Mine/selfinfo/MySetUp/Feedback/feedback';
import AboutUs from './routes/Mine/selfinfo/MySetUp/AboutUs/aboutUs';

// 学习
import CourseList from './routes/Study/course/courseList';
import Course from './routes/Study/course/course';
import Examination from './routes/Study/examination/examination';
import Interlocution from './routes/Study/interlocution/interlocution';
import InterlocutionItem from './routes/Study/interlocution/interlocutionItem';
import InterlocutionAdd from './routes/Study/interlocution/interlocutionAdd';

function RouterConfig({ app, history }) {
  history.listen(({ pathname }) => {
    const key = '_store';
    const store = app[key];
    const dispatch = store.dispatch;
    switch (pathname) {
      case '/login':
      case 'login':
        break;
      case '/':
        dispatch(routerRedux.replace('/home'));
        break;
      default: {
        const state = store.getState();
        const loggedIn = state.user.login;
        console.log(`当前登录状态：${loggedIn}`);
        if (loggedIn === false) dispatch(routerRedux.replace('/login'));
        break;
      }
    }
  });
  return (
    <Router history={history}>
      <Route>
        {/* 登录 */}
        <Route path="login" component={Login} />
        {/* 首页布局 */}
        <Route path="home" component={Layout} />
        {/* 资讯 */}
        <Route path="infor">
          {/* 详情 */}
          <Route path="trendDetail" component={TrendDetail} />
          <Route path="mienDetail" component={MienDetail} />
        </Route>
        {/* 消息 */}
        <Route path="news">
          {/* 党建圈 */}
          <Route path="partyCircle" >
            <IndexRoute component={PartyCircle} />
            {/* 发布党建圈 */}
            <Route path="newsAdd" component={NewsAdd} />
            {/* 党建圈图片详情 */}
            <Route path="photoDetail" component={PhotoDetail} />
          </Route>
          <Route path="partyCircle" component={PartyCircle} />
          {/* 新任务 */}
          <Route path="newTask" component={NewTask} />
          {/* 系统消息 */}
          <Route path="sysNews" component={SysNews} />
          {/* 会议通知 */}
          <Route path="meeting" component={Meeting} />
        </Route>
        {/* 工作台 */}
        <Route path="work">
          {/* 个人信息 */}
          <Route path="myinformmation" >
            <IndexRoute component={myinformmation} />
          </Route>
          {/* 组织生活 */}
          <Route path="life" >
            <IndexRoute component={Life} />
            <Route path="lifeparticulars" component={Lifeparticulars} />
          </Route>
          {/* 党费交纳 */}
          <Route path="dues" >
            <IndexRoute component={Dues} />
            <Route path="paymenthistory" component={Paymenthistory} />
          </Route>
          {/* 关系转接 */}
          <Route path="zzgx" >
            <IndexRoute component={ZZGX} />
            <Route path="applytransfer" component={ApplyTransferxx} />
            <Route path="transferdetails" component={TransferDetails} />
            <Route path="applyhistory" component={ApplyHistory} />
          </Route>
          {/* 在线学习 */}
          <Route path="zxxx" >
            <IndexRoute component={ZXXX} />
            <Route path="particular" component={Particular} />
          </Route>
          {/* 制度速查 */}
          <Route path="ZDSC" >
            <IndexRoute component={ZDSC} />
          </Route>
          {/* 沟通交流 */}
          <Route path="Communication" >
            <IndexRoute component={Communication} />
          </Route>
          {/* 个人积分 */}
          <Route path="GRJF" >
            <IndexRoute component={GRJF} />
          </Route>
          {/* 党务管理---组织管理 */}
          <Route path="zzadminister" >
            <IndexRoute component={zzadminister} />
            <Route path="partybuilding" component={Partybuilding} />
            <Route path="dangyuanlist" component={DangyuanList} />
          </Route>
          {/* 党员管理 */}
          <Route path="dyadminister" >
            <IndexRoute component={dyadminister} />
            <Route path="dyadministerChild" component={DyadministerChild} />
          </Route>
          {/* 党费管理 */}
          <Route path="dfadminister" >
            <IndexRoute component={dfadminister} />
          </Route>
          {/* 活动管理 */}
          <Route path="hdadminister" >
            <IndexRoute component={hdadminister} />
            <Route path="activityentry" component={Activityentry} />
          </Route>
          {/* 任务管理 */}
          <Route path="rwadminister" >
            <IndexRoute component={rwadminister} />
            <Route path="releasetask" component={Releasetask} />
            <Route path="rwaudit" component={RwAudit} />
            <Route path="rwrejectex" component={RwRejectex} />
          </Route>
          {/* 关系转接 */}
          <Route path="relation" >
            <IndexRoute component={Relation} />
            <Route path="relationlist" component={Relationlist} />
            <Route path="tparticulars" component={TParticulars} />
          </Route>
          {/* 党建监督 */}
          <Route path="djsupervises" >
            <IndexRoute component={djsupervises} />
          </Route>
          {/* 民主评议 */}
          <Route path="democraticappraisal" >
            <IndexRoute component={democraticappraisal} />
            <Route path="addappraisal" component={AddAppraisal} />
            <Route path="dreviewDetail" component={DreviewDetail} />
          </Route>
          {/* 党员帮扶 */}
          <Route path="dysupportxx" >
            <IndexRoute component={dysupportxx} />
            <Route path="support" component={Support} />
          </Route>
          {/* 党务报告 */}
          <Route path="dwreportlist" >
            <IndexRoute component={Dwreportlist} />
            <Route path="dwreportx" component={Dwreportx} />
          </Route>
          {/* 积分排行 */}
          <Route path="partyofintegralxx" >
            <IndexRoute component={partyofintegralxx} />
          </Route>
          {/* ------------------------------------------------------------------------------ */}
          {/* 组织架构 */}
          <Route path="orgArchitecture" >
            <IndexRoute component={OrgArchitecture} />
            {/* 组织详情 */}
            <Route path="orgDetail" component={OrgDetail} />
          </Route>

          {/* 任务管理 */}
          <Route path="taskManage" >
            <IndexRoute component={TaskManage} />
            {/* 任务发布 */}
            <Route path="taskAdd" component={TaskAdd} />
            {/* 任务开始 */}
            <Route path="taskStart" component={TaskStart} />
            {/* 任务进行 */}
            <Route path="taskGetOn" component={TaskGetOn} />
            {/* 任务完成 */}
            <Route path="complete" component={Complete} />
            {/* 任务未完成 */}
            <Route path="notComplete" component={NotComplete} />
          </Route>
          {/* 工作日志 */}
          <Route path="workLog" >
            <IndexRoute component={WorkLog} />
            {/* 添加工作日志 */}
            <Route path="workAdd" component={WorkAdd} />
            {/* 工作日志详情 */}
            <Route path="workDetails" component={WorkDetails} />
          </Route>
          {/* 信息发布 */}
          <Route path="inforRelease" >
            <IndexRoute component={InforRelease} />
            {/* 添加信息发布 */}
            <Route path="infroAdd" component={InfroAdd} />
            {/* 信息详情 */}
            <Route path="infroDetails" component={InforDetails} />
          </Route>
        </Route>

        {/* 学习 */}
        <Route path="study">
          {/* 课程 */}
          <Route path="courseList" component={CourseList} />
          <Route path="course" component={Course} />
          {/* 在线考试 */}
          <Route path="examination" component={Examination} />
          {/* 在线问答 */}
          <Route path="interlocution" >
            <IndexRoute component={Interlocution} />
            <Route path="details" component={InterlocutionItem} />
            <Route path="add" component={InterlocutionAdd} />
          </Route>
        </Route>

        {/* 我的 */}
        <Route path="selfinfo">
          {/* 个人详情 */}
          <IndexRoute component={Selfinfo} />
          {/* 修改密码 */}
          <Route path="changepwd" component={ChangePWD} />
          {/* 修改手机号 */}
          <Route path="changephone" component={ChangePhone} />
          {/* /!*积分页面*!/* /}
          {/* <Route path="point" component={Point} /> */}
          {/* 收藏页面 */}
          <Route path="collection" component={Collection} />
          {/* 任务页面 */}
          <Route path="task" component={Task} />
          {/* 任务详情 */}
          <Route path="taskparticulars" component={TaskParticulars} />
          {/* /!*电子卡页面*!/* /}
          {/* <Route path="mycard" component={MyCard} /> */}
          {/* /!*我管理的网站页面*!/* /}
          {/* <Route path="myweb" component={MyWeb} /> */}
          {/* 我管理的网站页面详情 */}
          <Route path="mywebinfo" component={MyWebInfo} />
          {/* 我的活动页面 */}
          <Route path="myactivity" component={MyActivity} />
          {/* 我的课程页面 */}
          <Route path="mycourse" component={MyCourse} />
          {/* 我的发布 */}
          <Route path="myrelease" component={MyRelease} />
          {/* 设置 */}
          <Route path="myset" component={MySetUp} />
          {/* 积分规则 */}
          <Route path="integralrule" component={IntegralRule} />
          {/* 使用指南 */}
          <Route path="useGuide" component={UseGuide} />
          {/* 意见反馈 */}
          <Route path="feedback" component={Feedback} />
          {/* 关于我们 */}
          <Route path="aboutUs" component={AboutUs} />
        </Route>
      </Route>
    </Router>
  );
}

export default RouterConfig;
